// Decompiled by DJ v3.5.5.77 Copyright 2003 Atanas Neshkov Date: 20/10/2005 02:04:46 p.m.
//Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
//Decompiler options: packimports(3)
//Source File Name: MayaMDK.java

package gurulab.maya.mdk;

import java.io.*;
import java.net.*;

public class MayaMDK{

    public MayaMDK() {
    }

    public static int enviarSMS(String pasaporte, String password, String codPaisDest, String codAreaDest, String numeroDest, String mensaje, String endpoint) throws Exception {
        setEndpoint(endpoint);
        String encodedPasaporte = URLEncoder.encode(pasaporte, "UTF-8");
        String encodedPassword = URLEncoder.encode(password, "UTF-8");
        String encodedCodPais = URLEncoder.encode(codPaisDest, "UTF-8");
        String encodedCodArea = URLEncoder.encode(codAreaDest, "UTF-8");
        String encodedNumLocal = URLEncoder.encode(numeroDest, "UTF-8");
        String encodedMensaje = URLEncoder.encode(mensaje, "UTF-8");
        StringBuffer call = new StringBuffer(endpoint + "/enviarSMS");
        call.append("?pasaporte=" + encodedPasaporte + "&password=" + encodedPassword + "&codPais=" + encodedCodPais + "&codArea=" + encodedCodArea + "&numRem=" + encodedNumLocal + "&mensaje=" + encodedMensaje);
        System.out.println("call=" + call);
        URL direccion = new URL(call.toString());
        java.net.URLConnection conexion = direccion.openConnection();
        HttpURLConnection conn = (HttpURLConnection) conexion;
        conn.setRequestMethod("GET");
        conn.addRequestProperty("pasaporte", pasaporte);
        conn.addRequestProperty("password", password);
        conn.addRequestProperty("codPais", codPaisDest);
        conn.addRequestProperty("codArea", codAreaDest);
        conn.addRequestProperty("numeroDest", numeroDest);
        conn.addRequestProperty("mensaje", mensaje);
        InputStreamReader isr = new InputStreamReader(conn.getInputStream());
        BufferedReader br = new BufferedReader(isr);
        String temp;
        String response;
        for (response = ""; (temp = br.readLine()) != null; response = response + temp)
            ;
        br.close();
        isr.close();
        conn.disconnect();
        System.out.println("result=" + response);
        try {
            return (new Integer(response)).intValue();
        } catch (Exception e) {
            return -101;
        }
    }
    
    public static int enviarSMS(String pasaporte, String password, String codPaisDest, String codAreaDest, String numeroDest, String mensaje) throws Exception {
        String encodedPasaporte = URLEncoder.encode(pasaporte, "UTF-8");
        String encodedPassword = URLEncoder.encode(password, "UTF-8");
        String encodedCodPais = URLEncoder.encode(codPaisDest, "UTF-8");
        String encodedCodArea = URLEncoder.encode(codAreaDest, "UTF-8");
        String encodedNumLocal = URLEncoder.encode(numeroDest, "UTF-8");
        String encodedMensaje = URLEncoder.encode(mensaje, "UTF-8");
        StringBuffer call = new StringBuffer(endpoint + "/enviarSMS");
        call.append("?pasaporte=" + encodedPasaporte + "&password=" + encodedPassword + "&codPais=" + encodedCodPais + "&codArea=" + encodedCodArea + "&numRem=" + encodedNumLocal + "&mensaje=" + encodedMensaje);
        System.out.println("call=" + call);
        URL direccion = new URL(call.toString());
        java.net.URLConnection conexion = direccion.openConnection();
        HttpURLConnection conn = (HttpURLConnection) conexion;
        conn.setRequestMethod("GET");
        conn.addRequestProperty("pasaporte", pasaporte);
        conn.addRequestProperty("password", password);
        conn.addRequestProperty("codPais", codPaisDest);
        conn.addRequestProperty("codArea", codAreaDest);
        conn.addRequestProperty("numeroDest", numeroDest);
        conn.addRequestProperty("mensaje", mensaje);
        InputStreamReader isr = new InputStreamReader(conn.getInputStream());
        BufferedReader br = new BufferedReader(isr);
        String temp;
        String response;
        for (response = ""; (temp = br.readLine()) != null; response = response + temp)
            ;
        br.close();
        isr.close();
        conn.disconnect();
        System.out.println("result=" + response);
        try {
            return (new Integer(response)).intValue();
        } catch (Exception e) {
            return -101;
        }
    }    

    public static int configurarURLReceptorSMS(String pasaporte, String password, String receptor, String clave) {
        return -101;
    }

    public static int recibirSMS(String pasaporte, String password) {
        return -101;
    }

    public static int responderSMS(String pasaporte, String password, String codPaisDest, String codAreaDest, String numeroDest, String mensaje, String idMensaje) throws Exception {
        return -101;
    }

    public static int pararRecepcion(String pasaporte, String password) {
        return -101;
    }

    public static String endpoint = "http://mercurio.tedexis.com:8081/merlin/mercurio";

    /**
     * @return Devuelve endpoint.
     */
    public static String getEndpoint() {
        return endpoint;
    }

    /**
     * @param endpoint
     *            El endpoint a establecer.
     */
    public static void setEndpoint(String endpoint) {
        MayaMDK.endpoint = endpoint;
    }
}